<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="javax.servlet.http.*,com.vince.model.domain.*" %>
    <%@taglib prefix='c' uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
 body{
   background-image: url("<%=request.getContextPath()%>/view/images/0452.jpg");
   
 }
</style>
<script type='text/javascript'>
function check(){
	if(form1.name.value==null||form1.name.value==""){
		 alert("用户名不能为空");
		 form1.name.focus();
		 return false;
	}
	if(form1.pwd.value==null||form1.pwd.value==""){
		 alert("密码不能为空");
		 form1.pwd.focus();
		 return false;
	}
	if(form1.qx.value==null||form1.qx.value==""){
		alert("请选择用户类型");
		//form1.qx.focus();
		return false;
		
	}
	return true;
}

</script>
<!--浏览器发送http请求时，有cookie会在http请求头附加cookie信息  -->
<%
String name="";
String pwd="";
 Cookie[] cookies=request.getCookies();
 if(cookies!=null){
	 for(int j=0;j<cookies.length;j++){
		 System.out.println(cookies[j].getName());
		 if("username".equals(cookies[j].getName())){
			 name=cookies[j].getValue();
		 }
		 if("password".equals(cookies[j].getName())){
			 pwd=cookies[j].getValue();
		 }
		/*  if(name!=null&&name!=""&&pwd!=""&&pwd!=null){
			 response.sendRedirect(request.getContextPath()+"/servlet/loginservlet?name="+name+"&pwd="+pwd);//重定向到登录验证模块
		 } */
	 }
 }
%>

</head>
<body>
<h2>用户登录界面</h2>
  <form action="<%=request.getContextPath()%>/servlet/loginservlet"  onsubmit="return check()" method="get" name="form1">
    姓名<input type="text" name="name" value="<%=name %>"><br/>
    密码<input type="password" name="pwd" value="<%=pwd %>"><br/>
    <input type="radio" name="qx" value="adminer">管理员
    <input type="radio" name="qx" value="user">用户<br/>
    自动登录
    <input type="checkbox"  name="islogin" value="y">是
    <input type='checkbox' name="islogin" value='n'>否
    <br/>
    <input type="submit"  value="登录">
     <c:choose>
     <c:when test="${not empty requestScope.message}"><font color="red">*${requestScope.message }</font></c:when>
     <c:otherwise></c:otherwise>  
  </c:choose>
  </form>
  <br/>
  <br/>
  <input type="submit" onclick="document.location.href='<%=request.getContextPath()%>/view/share/register/register.jsp'" value="如果还未注册，请先注册"> 
</body>
</html>